package com.huike.controller.aitivity;


import com.huike.dto.ActivityDto;
import com.huike.result.PageResult;
import com.huike.result.Result;
import com.huike.service.ActivityService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 活动管理
 */
@RestController
@RequestMapping("/activity")
public class activityController {
    @Autowired
    private ActivityService activityService;
    /**
     * 分页查询
     * @param dto
     * @return
     */
    @GetMapping("/page")
    public Result<PageResult> findAll(ActivityDto dto) {
        PageResult pageResult = activityService.findAll(dto);
        return Result.success(pageResult);
    }

    /**
     * 新增活动
     * @param dto
     * @return
     */
    @PostMapping("/add")
    public Result add(@RequestBody ActivityDto dto) {
        activityService.add(dto);
        return Result.success();
    }
    /**
     * 删除
     * @param ids
     * @return
     */
    @DeleteMapping("/{ids}")
    public Result delete(@PathVariable Integer ids) {
        activityService.delete(ids);
        return Result.success();
    }

    /**
     * 修改
     * @param dto
     * @return
     */
    @PutMapping("/update")
    public Result update(@RequestBody ActivityDto dto) {
        activityService.updateactivity(dto);
        return Result.success();
    }

    /**
     * 回显数据
     * @param id
     * @return
     */
    @GetMapping("/find/{id}")
    public Result findById(@PathVariable Integer id){
     return  activityService.findById(id);
}

    /**
     *渠道
     * @return
     */
    @GetMapping("/clues_item")
    public Result clues() {
        String activityClues = "clues_item";
        return activityService.clusm(activityClues);
    }

    /**
     * 活动类型
     * @return
     */
    @GetMapping("/channel_type")
    public Result channel() {
        String activitychannel = "channel_type";
        return activityService.channel(activitychannel);
    }

}
